<!DOCTYPE html>
<html lang="zh" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('彩民抽奖信息库列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>抽奖期号：</label>
                            <input name="termNo" type="text"/>
                        </li>
                        <li>
                            <label>彩民姓名：</label>
                            <input name="userName" type="text"/>
                        </li>
                        <li>
                            <label>身份证号：</label>
                            <input name="idCard" type="text"/>
                        </li>
                        <li>
                            <label>手机号码：</label>
                            <input name="mobile" type="text"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:lucky:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:lucky:add">
                <i class="fa fa-plus"></i> 手动添加
            </a>
            -->
            <a class="btn btn-primary" onclick="startDraw()"
               shiro:hasPermission="system:lucky:draw">
                <i class="fa fa-wpforms"></i> 开始抽奖
            </a>
            <a class="btn btn-info" onclick="clearData()"
               shiro:hasPermission="system:lucky:clear">
                <i class="fa fa-remove"></i> 数据初始化
            </a>
            <a class="btn btn-info" onclick="$.table.importExcel()"
               shiro:hasPermission="system:lucky:import">
                <i class="fa fa-upload"></i> 抽奖数据导入
            </a>
            <a class="btn btn-warning" onclick="exportSelected()"
               shiro:hasPermission="system:lucky:export">
                <i class="fa fa-download"></i> 抽奖结果导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
        <div>
            <input class="form-control" id="luckyHtmlUrl" th:value="${luckyHtmlUrl}" type="hidden">
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var removeFlag = [[${@permission.hasPermi('system:lucky:remove')}]];
    var prefix = ctx + "system/lucky";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            removeUrl: prefix + "/remove",
            clearUrl: prefix + "/clear",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            modalName: "彩民抽奖信息库",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '${comment}',
                    visible: false
                },
                {
                    field: 'termNo',
                    title: '抽奖期号'
                },
                {
                    field: 'userName',
                    title: '彩民姓名'
                },
                {
                    field: 'idCard',
                    title: '身份证号'
                },
                {
                    field: 'mobile',
                    title: '手机号码'
                }
                /*,
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }*/
            ]
        };
        $.table.init(options);
    });

    // 清空数据
    function clearData() {
        var tipMsg = "确定清空所有数据吗？";
        $.modal.confirm(tipMsg, function () {
            $.post(prefix + "/clear", null, function (result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = prefix;
                } else {
                    $.modal.alertError(result.msg);
                }
            });
        });
    }

    // 导出数据
    function exportSelected() {
        var dataParam = $("#export-form").serializeArray();
        var tipMsg = "确定导出抽奖结果数据吗？";
        $.modal.confirm(tipMsg, function () {
            $.post(prefix + "/exportData", dataParam, function (result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + false;
                } else {
                    $.modal.alertError(result.msg);
                }
            });
        });
    }

    //打开抽奖
    function startDraw() {
        var url = document.getElementById("luckyHtmlUrl").value;
        // window.open("http://192.168.31.111:82")
        // window.open(url);
        window.open(url ,'_blank', "height="+(screen.availHeight - 0)+",width="+(screen.availWidth - 0)+", fullscreen=yes,channelmode=yes, titlebar=no, top=0, left=0,toolbar=no, menubar=no, scrollbars=no, location=no, status=no");
    }

</script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>